var fs = require("fs"),    
    request = require('request'),
    Promise = require("bluebird");

function uploadFileP() {
    return new Promise(function (resolve) {
        fs.writeFile("fuck.txt", function (err) {
            if (err) {
                console.log("write fiel err");
            } else {
                console.log("write succ");
                resolve("fuck");
            }
        })
    });
}


function uploadFile() {
    fs.writeFile("fuck.txt", function (err) {
        if (err) {
            console.log("write fiel err");
        } else {
            console.log("write succ");
            resolve("fuck");
        }
    })
}

function* addDish() {
    var uf = Promise.promisify(uploadFile);
    var p = yield uf;
    console.log("addDish return value : ", p)
    return p;
}

// var iter = addDish();
// // iter.next().value 就是拿到手的promise
// var p = iter.next().value
// console.log("1");
// p.then(function (value) {
//     console.log("return vaule is ", value);
// })
// console.log("2");
